﻿using System;
using System.Runtime.CompilerServices;
using Microsoft.Scripting.Runtime;

namespace Cjc.Calculation.ExpressionEngine.Excel.Runtime.Operations
{
	public static class DecimalOps
	{
        //
        // See Int32Ops for a description of the conversion methods
        //
        [SpecialName, ImplicitConversionMethod]
        public static string ConvertToString(decimal x) { return x.ToString(); }

        [SpecialName, ImplicitConversionMethod]
        public static bool ConvertToBoolean(decimal x) { return x != 0; }

        [SpecialName,ImplicitConversionMethod]
        public static decimal ConvertToDecimal(bool x) { return x ? 1 : 0; }

        //
        // See Int32Ops for a description of the operation methods
        //
        [SpecialName]
		public static object Add( decimal x, decimal y ) { return x + y; }
		[SpecialName]
		public static object Subtract( decimal x, decimal y ) { return x - y; }
		[SpecialName]
		public static object Multiply( decimal x, decimal y ) { return x * y; }
		[SpecialName]
		public static object Divide( decimal x, decimal y ) { return x / y; }

		[SpecialName]
		public static bool Equals( decimal x, decimal y ) { return ( x == y ); }
		[SpecialName]
		public static bool GreaterThan( decimal x, decimal y ) { return ( x > y ); }
		[SpecialName]
		public static bool GreaterThanOrEqual( decimal x, decimal y ) { return ( x >= y ); }
		[SpecialName]
		public static bool LessThan( decimal x, decimal y ) { return ( x < y ); }
		[SpecialName]
		public static bool LessThanOrEqual( decimal x, decimal y ) { return ( x <= y ); }
		[SpecialName]
		public static bool NotEquals( decimal x, decimal y ) { return ( x != y ); }
	}
}